package org.halk;

import org.halk.config.CustomHolidayProperties;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.ApplicationPidFileWriter;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@SpringBootApplication
@RestController
public class PackageDemoApplication {

    @Value("${halk.name}")
    private String name;

    @Resource
    private CustomHolidayProperties customHolidayProperties;

    @GetMapping("/get")
    public List<String> getStr() {
        List<String> holidayNameList = customHolidayProperties.getHolidayNameList();
        return holidayNameList;
    }

    /**
     * 用来验证yml配置文件的优先级，配置多个后看看哪个生效
     * @return
     */
    @GetMapping("/name")
    public String getHello() {
        return name;
    }

    public static void main(String[] args) {
        SpringApplication application = new SpringApplication(PackageDemoApplication.class);
        application.addListeners(new ApplicationPidFileWriter("package_demo.pid"));
        SpringApplication.run(PackageDemoApplication.class, args);
    }

}
